<?php
namespace Modules\ShopAdmin\Models;
class ShopUserInfo extends BaseShopModel
{	
	/**
     * @name  关联用户
     */
    public function user_one()
    {
        return $this->hasOne('Modules\Admin\Models\User','id','user_id');
    }
	private function gender_list(){
		return [
			'0'=>'未知',
			'1'=>'男',
			'2'=>'女',
		];
	}
	/**
     * @name  列表数据处理
     */
	public function data_image($data){ 
		$gender = $this->gender_list();
		foreach($data as $k=>$v){
			$data[$k]['gender'] = $gender[$v['user_one']['gender']];
			$data[$k]['nick_name'] = $v['user_one']['nick_name'];
			$data[$k]['phone'] = $v['user_one']['phone'];
			if(isset($v['user_one']['image_one']['status']) && $v['user_one']['image_one']['status'] == 1){
				$data[$k]['image'] = $v['user_one']['image_one']['url'];
			}else{
				$data[$k]['image'] = $v['user_one']['avatar_url'];
			}
			unset($data[$k]['user_one'],$data[$k]['user_id'],$data[$k]['updated_at']);
		}
		return $data;
	}
}
